package org.box.metadata.shell;

import java.util.Set;

import org.box.metadata.cli.annotation.Command;
import org.box.metadata.shell.exception.TerminatedException;

/**
 * <p>
 * Describes a basic API for Shell's implementation in terms of meta-CLI
 * framework.
 * </p>
 * 
 * <p>
 * API provide just two methods to run a shell, a method which returns a list of
 * available applications in the shell and a method to display messages to the
 * User:
 * 
 * <li> {@link #run(String[])} and {@link #runAndExit(String[], CommandHandler)} -
 * run a shell
 * <li> {@link #getCommands()} - returns a list of exposed application
 * </p>
 * 
 * @see CommandHandler
 * 
 * @author <a href="mailto:alexander.box@gmail.com">Alexander Korobka</a>
 * 
 */
public interface Shell {
	

	/**
	 * Runs a shell with the given list of Command Line arguments that have to
	 * be translated to the Shell's prompt line
	 * 
	 * @param initArgs
	 *            - the list of arguments.
	 */
	void run(String[] initArgs);

	/**
	 * Runs a shell with the given list of Command Line arguments and a single
	 * application which have to be executed immediately with the given list of
	 * argument and the Shell have to be closed immediately after the
	 * application's end
	 * 
	 * @param initArgs
	 *            - the list of arguments.
	 */
	void runAndExit(String[] args) throws TerminatedException;

	/**
	 * Displays message from the Shell or Shell's application to the user
	 * 
	 * @param msg - a message to display to
	 */
	void displayMessage(String msg);

	void exit();

	@SuppressWarnings("rawtypes")
	Class[] getCfgClasses();

	Set<Command> getCommands();
	
	void addListener(CommandHandlerListener listener);
	
	void removeListener(CommandHandlerListener listener);

}
